package com.iexbuy.ihg.ui.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RatingBar;

import com.iexbuy.ihg.App;
import com.iexbuy.ihg.R;
import com.iexbuy.ihg.adapter.RecommentListAdapter;
import com.iexbuy.ihg.common.ExtraKeyConstant;
import com.iexbuy.ihg.entity.ReComment;
import com.iexbuy.ihg.entity.ReCommentResponse;
import com.iexbuy.ihg.net.ServiceHelper;
import com.iexbuy.ihg.utils.JsonUtils;
import com.iexbuy.ihg.utils.ToastUtils;
import com.jingchen.pulltorefresh.PullToRefreshLayout;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class WeDeCommentDetailFragment extends BaseFragment {

	private static WeDeCommentDetailFragment homeFragmentInstent;

	@ViewInject(R.id.msgListLayout)
	private PullToRefreshLayout msgListRefreshLayout;
	@ViewInject(R.id.ratingBar)
	private RatingBar ratingBar;
	@ViewInject(R.id.commentText)
	private EditText commentText;

	private static ReComment reCommentObject;

	private List<ReComment> reCommentResponses = new ArrayList<ReComment>();
	private int pageNo = 0;
	private RecommentListAdapter recommentListAdapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		homeFragmentInstent = this;
	}

	@Override
	protected View _onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_wede_padding_comment, container, false);
		ViewUtils.inject(this, rootView);
		initView(rootView);
		return rootView;
	}

	private void initView(View rootView) {
		mBaseActivity.setTitle(getResources().getString(R.string.we_de_cashs));
		mBaseActivity.setTitleLayoutVisibility(true);
		mBaseActivity.setHomeActivity(false);
		mBaseActivity.setRightButton("提交", new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				submitComment();
			}
		});

	}


	private void submitComment() {
		if (ratingBar.getRating() == 0) {
			ToastUtils.toast(mBaseActivity, "请点选星级评价。");
			return;
		}

	}


	public static void setReCommentObject(ReComment reCommentObject) {
		WeDeCommentDetailFragment.reCommentObject = reCommentObject;
	}

	/**
	 * @return the homeFragmentInstent
	 */
	public static WeDeCommentDetailFragment getHomeFragmentInstent() {
		return homeFragmentInstent;
	}

}
